package com.wzb.mybatisplus.bitaction;

public class WIFToPublicKeyTest {
    final String ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";



    public static void main(String[] args) {
        // 测试用的WIF私钥（请勿在主网使用）
        String[] testWIFKeys = {
                "L4DG9sBdUBLMfhvYrDy19TgY11ZEfs1FCuvDYJSj9oSbZDrfeeUK", // 非压缩WIF
                "KwdMAjGmerYanjeui5SHS7JkmpZvVipYvB2LJGU1ZxJwYvP98617", // 压缩WIF
                "L4gBfDgYfR5Ddb9sZfT3jqk8pXvF5VQ6bR2mJ6X7tNwYc1zA4qC3"  // 压缩WIF
        };

        System.out.println("=== 单个转换测试 ===");
        for (String wif : testWIFKeys) {
            try {
                String publicKey = BitcoinWIFConverter.wifTo34CharPublicKey(wif);
                boolean is34Char = BitcoinWIFConverter.is34CharPublicKey(publicKey);

                System.out.println("WIF: " + wif);
                System.out.println("34字符公钥: " + publicKey);
                System.out.println("长度验证: " + (is34Char ? "✓ 34个字符" : "✗ 不是34个字符"));
                System.out.println("长度: " + publicKey.length() + " 字符");
                System.out.println("---");
            } catch (Exception e) {
                System.out.println("错误 - WIF: " + wif);
                System.out.println("错误信息: " + e.getMessage());
                System.out.println("---");
            }
        }

        System.out.println("\n=== 批量转换测试 ===");
        BitcoinWIFConverter.ConversionResult batchResult =
                BitcoinWIFConverter.BatchConverter.convertMultiple(testWIFKeys);

        System.out.println("成功: " + batchResult.getSuccessCount() +
                ", 失败: " + batchResult.getFailureCount());

        for (BitcoinWIFConverter.SuccessRecord success : batchResult.getSuccesses()) {
            System.out.println("✓ " + success.getWif() + " → " + success.getPublicKey() +
                    " (" + success.getPublicKey().length() + "字符)");
        }

        System.out.println("\n=== 完整公钥信息 ===");
        for (String wif : testWIFKeys) {
            try {
                BitcoinWIFToPublicKey.PublicKeyInfo info =
                        BitcoinWIFToPublicKey.getPublicKeyInfo(wif);
                System.out.println(info);
                System.out.println("---");
            } catch (Exception e) {
                System.out.println("错误: " + e.getMessage());
            }
        }
    }
}